package com.daocao.sysuser.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.daocao.common.domain.entity.UmsUserCard;
import com.daocao.common.response.DaoCaoResult;
import com.daocao.common.service.IUmsUserCardService;

import jakarta.validation.Valid;

@RestController
@RequestMapping("sys/userCard")
public class UserCardController {

    @Autowired
    private IUmsUserCardService cardStatusService;

    @GetMapping("/status")
    public DaoCaoResult searchCardList() {
        return DaoCaoResult.success(cardStatusService.selectCardList());
    }

    @PutMapping
    public DaoCaoResult updateCardStatus(@Valid @RequestBody UmsUserCard umsUserCard) {
        int row = cardStatusService.updateCardStatus(umsUserCard);
        if(row > 0) {
            return DaoCaoResult.success();
        }
        return DaoCaoResult.error("修改Card失败");
    }
}
